home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 2967 < prev    next >
Encoding:
Text File  |  1996-08-06  |  1.3 KB  |  48 lines

  1. Newsgroups: comp.lang.c++
  2. Path: uu4news.netcom.com!lavc!lavc!mlf
  3. From: mlf@support.com
  4. Subject: GETTING THE SYSTEM TI
  5. Message-ID: <9601201624.0N1GW01@support.com>
  6. Organization: L.A. Valley College Public BBS (818)985-7150
  7. X-Mailer: TBBS/PIMP v3.35
  8. Distribution: world
  9. Date: Sat, 20 Jan 96 16:24:04 -0800
  10.  
  11.  
  12.  Ne> From: tate@netwest.com (Tate Griffin)
  13.  Ne> Newsgroups: comp.lang.c++
  14.  Ne> Subject: Getting the system time and date
  15.  Ne> Date: Fri, 19 Jan 1996 23:52:34 MST
  16.  Ne> Organization: Netwest
  17.  
  18.  Ne> How do I get the current time and date from a PC using C++?
  19.  
  20.  
  21. Here try this:
  22.  
  23. // DATETIME.CPP (written for BORLAND TURBO C++ 3.0 for DOS)
  24.  
  25. #include <conio.h>
  26. #include <time.h>
  27.  
  28. int main(void) {
  29.   struct tm *time_now;
  30.   time_t secs_now;
  31.   char str[80];
  32.  
  33.   tzset(); time(&secs_now);
  34.   time_now = localtime(&secs_now);
  35.   strftime(str, 80, "%A, %B %d, %Y, %I:%M:%S %p (%Z)", time_now);
  36.   cprintf("\r\n%s\r\n\r\n",str);
  37.   return(0);
  38. }
  39.  
  40.  ------------------------------------------------------------
  41. + Mike Flower            +         Software Designer         +
  42. + 10227 Langmuir Ave.    + >>>>>> Available for hire <<<<<<  +
  43. + Sunland, CA  91040     + Call now for an interview, Today! +
  44. + email: MLF@support.com +           818/353-8394            +
  45.  ------------------------------------------------------------
  46.  
  47. ___ Blue Wave/QWK v2.12
  48.